<template>
    <div class="reportCard">
        <template  v-if="cardData.dataList">
            <div class="cardBox">
                <!-- <div class="card" v-for="(item,index) in cardData.dataList" :key="index" @click="jumpList(item)"> -->
                <div
                    class="card"
                    v-for="(item, index) in cardData.dataList"
                    :key="index"
                >
                    <div class="check-status">
                        <i
                            v-if="item.examineState == 0"
                            class="el-icon-edit push"
                        ></i>
                        <i
                            v-if="item.examineState == 1"
                            class="el-icon-remove noChecked"
                        ></i>
                        <i
                            v-if="item.examineState == 2"
                            class="el-icon-success checked"
                        ></i>
                        <i
                            v-if="item.examineState == 3"
                            class="el-icon-error error"
                        ></i>
                    </div>
                    <div class="card-item">
                        <div class="top">
                            <div class="title">{{ item.reportName }}</div>
                            <div class="subTitle">{{ item.rangeName }}</div>
                            <!-- <div class="year">编制年份：{{ item.year }}年</div> -->
                        </div>
                        <div class="bottom">
                            <p>{{ item.objectName }}</p>
                            <p>编制部门：{{ item.preparationDepartment }}</p>
                        </div>
                    </div>
                    <div class="card-radio">
                        <div class="preview" @click.stop="upload(item)">
                            <i class="el-icon-upload2"></i
                            ><span class="pl-5">上传</span>
                        </div>
                        <!-- v-permission="queryPermission"  -->
                        <div class="upload" @click="download(item)">
                            <i class="el-icon-download"></i
                            ><span class="pl-5">下载</span>
                        </div>
                        <div
                            class="preview upload-2"
                            @click.stop="remove(item)"
                        >
                            <i class="el-icon-delete"></i
                            ><span class="pl-5">删除</span>
                        </div>
                    </div>
                </div>
            </div>
            <!-- 分页 -->
            <div class="margin-t-10 margin-b-10 text-center">
                <el-pagination
                    @current-change="changePage"
                    :current-page.sync="searchFrom.pageIndex"
                    :page-size="searchFrom.pageSize"
                    layout="prev, pager, next, jumper"
                    prev-text="上一页"
                    next-text="下一页"
                    :total="cardData.total"
                >
                </el-pagination>
            </div>
        </template>
        <div class="emptyText" v-else>
            暂无数据
        </div>
    </div>
</template>

<script>
import { downloadReport, delectReoprt } from '@/api/report';
export default {
    name: 'reportCard',
    props: {
        cardData: {
            type: Object
        }
    },
    data () {
        return {
            searchFrom: {
                pageIndex: 1,
                pageSize: 10
            },
            // 报告名称
            reportName: '',
            // 目标id
            targetStandardId: ''
        };
    },
    methods: {
        // 切换页码
        changePage (val) {
            this.searchFrom.pageIndex = val;
            this.$emit('changePage', this.searchFrom);
        },
        // 跳转至详情
        // jumpList(item) {
        //   this.$emit('jumpList', item)
        // }
        // 上传
        upload (item) {
            console.log(item, 'item');
            // if (item.reportEditStatus === 0) {
            //     this.message('info', '此报告已过可编辑日期!');
            //     return;
            // }
            this.$emit('addAssert', this.$route.query.name);
            this.$emit('getParam', item.id);
        },
        // 下载
        download (row) {
            window.open(this.baseURL + `/v1/pc/api/file/fileDownload?fileName=${row.reportName}&filePath=${row.filePath}`, '_self')
            // console.log(this.ruleForm.fileVal, this.targetStandardId);
            // this.$refs[formName].validate(valid => {
            //     if (valid) {
            //         const str = this.$route.path.split('/');
            //         downloadReport({
            //             id: this.targetStandardId,
            //             wordUrl: this.wordUrl,
            //             reportType: str[str.length - 1]
            //         }).then(res => {
            //             // console.log(res, 'rest');
            //             this.common.downloadFile(res);
            //             this.centerDialogVisible = false;
            //         });
            //     }
            // });
        },
        remove (item) {
            delectReoprt(item.id).then(res => {
                this.$message.success('删除成功');
                this.$emit('getList');
            });
        }
    }
};
</script>

<style lang="scss" scoped>
@import "../../assets/css/reprotCard.scss";
.reportCard {
    padding: 20px;
}
</style>
